<html>
<head><meta charset="utf-8"><title>combining const bounds · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html">combining const bounds</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223882201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223882201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223882201">(Jan 25 2021 at 11:09)</a>:</h4>
<p>is it possible to write a bound that is satisfyable here? I don't think we have any logic for substituting const evaluatable bounds, right?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_evaluatable_checked, const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Generic</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">K</span>: <span class="kt">u64</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">ConstU64</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">K</span>: <span class="kt">u64</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">K</span>: <span class="kt">u64</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Generic</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">ConstU64</span><span class="o">&lt;</span><span class="p">{</span><span class="n">K</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span><span class="o">&gt;</span>: <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">K</span>: <span class="kt">u64</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Generic</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">ConstU64</span><span class="o">&lt;</span><span class="p">{</span><span class="n">K</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span><span class="o">&gt;</span>:<span class="p">,</span><span class="w"> </span><span class="n">ConstU64</span><span class="o">&lt;</span><span class="p">{</span><span class="n">K</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span><span class="o">&gt;</span>:<span class="p">,</span><span class="w"> </span><span class="n">ConstU64</span><span class="o">&lt;</span><span class="p">{</span><span class="n">K</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span><span class="o">&gt;</span>: <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="nc">Generic</span><span class="o">&lt;</span><span class="p">{</span><span class="n">K</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">}</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Generic</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="n">x</span><span class="p">.</span><span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="223888534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223888534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223888534">(Jan 25 2021 at 12:18)</a>:</h4>
<p>yeah, i think doesn't quite work how we want</p>



<a name="223888578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223888578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223888578">(Jan 25 2021 at 12:19)</a>:</h4>
<p>for that we would have to recurse into the unevaluated consts in <code>try_unify</code> i think</p>



<a name="223891540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223891540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223891540">(Jan 25 2021 at 12:48)</a>:</h4>
<p>what I was wondering is whether we can essentially substitute abstract consts. So if we have a replacement <code>K</code> -&gt; <code>M + 1</code>, then we could insert the abstract const nodes from <code>M + 1</code> and replace all uses of <code>K</code> with the ids of the newly inserted nodes</p>



<a name="223891606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223891606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223891606">(Jan 25 2021 at 12:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/combining.20const.20bounds/near/223888578">said</a>:</p>
<blockquote>
<p>for that we would have to recurse into the unevaluated consts in <code>try_unify</code> i think</p>
</blockquote>
<p>yeah, that's pretty much what meant here ^^</p>



<a name="223891615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223891615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223891615">(Jan 25 2021 at 12:49)</a>:</h4>
<p>kk <span aria-label="grinning" class="emoji emoji-1f600" role="img" title="grinning">:grinning:</span></p>



<a name="223891634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/combining%20const%20bounds/near/223891634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/combining.20const.20bounds.html#223891634">(Jan 25 2021 at 12:49)</a>:</h4>
<p>didn't explain myself well though</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>